package com.glsc.ngateway.common.base.dto.opmanage.report;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

/**
 * @author libj
 * @date 2020/11/04
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DerivativeResponse<T> implements Serializable {
    private int status;
    private String msg;
    private T data;

    public DerivativeResponse() {
    }

    public DerivativeResponse(int status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static <T> DerivativeResponse error(String msg, T data) {
        return new DerivativeResponse(-1, msg, data);
    }

    public static <T> DerivativeResponse fileError(String msg, T data) {
        return new DerivativeResponse(-2, msg, data);
    }

    public static DerivativeResponse error(String msg) {
        return new DerivativeResponse(-1, msg, null);
    }

    public static <T> DerivativeResponse success(String msg, T data) {
        return new DerivativeResponse(0, msg, data);
    }

    public static <T> DerivativeResponse success(T data) {
        return new DerivativeResponse(0, "ok", data);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "DerivativeResponse{" +
                "status=" + status +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
